1 package jrre.unittests.datastructures;
2
3 public class QuickSorter {
4
5 public void quickSort(int [] data, int lower, int upper){
6
7 int i;
8 int j;
9 int pivot = partition(data, lower, upper);
10
11 if(lower < pivot)
12 quickSort(data, lower, pivot - 1);
13
14 if(upper > pivot)
15 quickSort(data, pivot + 1, upper);
16
17 return;
18 }
19
20 public int partition(int [] data, int left, int right){
21
22 int pivot;
23 int temp;
24
25 pivot = data[left];
26
27 while(left < right){
28
29
30 while(data[right] >= pivot && left < right)
31 right--;
32
33
34 if(right != left){
35 data[left] = data[right];
36 left++;
37 }
38
39
40 while(data[left] <= pivot && left < right)
41 left++;
42
43 if(right != left){
44 data[right] = data[left];
45 right--;
46 }
47 }
48
49 data[left] = pivot;
50 return left;
51 }
52 }
This page was automatically generated by Maven